import Vue from 'vue'
import App from './App.vue'
import { initRouter } from './router'
import './theme/index.less'
import Antd from 'ant-design-vue'
import Viser from 'viser-vue'
// import '@/mock'
import store from './store'
import 'animate.css/source/animate.css'
import '@/assets/style.css'
import Plugins from '@/plugins'
import { initI18n } from '@/utils/i18n'
import bootstrap from '@/bootstrap'
import 'moment/locale/zh-cn'

import axios from './plugins/axios';
Vue.use(axios)

const Pusher = window.Pusher
Pusher.logToConsole = true

const WebsocketUrl = process.env.VUE_APP_WEBSOCKET_URL
const WebsocketPort = process.env.VUE_APP_WEBSOCKET_PORT
const WebsocketKey = process.env.VUE_APP_WEBSOCKET_KEY
const pusher = new Pusher(WebsocketKey, {
  wsHost: WebsocketUrl,
  wsPort: WebsocketPort,
  forceTLS: false,
  disableStats: true,
})

pusher.connection.bind('connected', function () {
  sessionStorage.setItem('socket-id', pusher.connection.socket_id)
})
const channel = pusher.subscribe('seller-channel')
Vue.prototype.$channel = channel


const router = initRouter(store.state.setting.asyncRoutes)
const i18n = initI18n('CN', 'US')

Vue.use(Antd)
Vue.config.productionTip = false
Vue.use(Viser)
Vue.use(Plugins)

bootstrap({ router, store, i18n, message: Vue.prototype.$message })

new Vue({
  router,
  store,
  i18n,
  render: h => h(App),
}).$mount('#app')

export { router }
